#pragma once

typedef enum {
    AC_SWITCH_Off = 0x00,
    AC_SWITCH_On = 0x01
}AC_SWITCH_Typedef;

typedef enum {
    AC_MODE_Invalid = 0x00,
    AC_MODE_Automatic = 0x10,
    AC_MODE_Refrigeration = 0x01,
    AC_MODE_Heating = 0x08,
    AC_MODE_Airsupply = 0x04,
    AC_MODE_Floorheating = 0x12,
    AC_MODE_Dehumidification = 0x20,
    AC_MODE_Dehumidification_Reheating = 0x02,
    AC_MODE_Heating_Underfloorheating = 0x40,
}AC_MODE_Typedef;

typedef enum {
    AC_FAN_SPEED_Invalid = 0x00,
    AC_FAN_SPEED_Automatic = 0x80,
    AC_FAN_SPEED_UltraLowSpeed = 0x01,
    AC_FAN_SPEED_LowSpeed = 0x02,
    AC_FAN_SPEED_MediumLowSpeed = 0x03,
    AC_FAN_SPEED_MediumSpeed = 0x04,
    AC_FAN_SPEED_MediumHighSpeed = 0x05,
    AC_FAN_SPEED_HighSpeed = 0x06,
    AC_FAN_SPEED_UltraHighSpeed = 0x07
}AC_FAN_SPEED_Typedef;

typedef enum {
    AC_LOCK_Unlock = 0x00,
    AC_LOCK_Switch = 0x01,
    AC_LOCK_Temperature = 0x02,
    AC_LOCK_Mode = 0x03,
    AC_LOCK_Speed = 0x04,
    AC_LOCK_Switch_Temperature = 0x05,
    AC_LOCK_Switch_Mode = 0x06,
    AC_LOCK_Switch_Speed = 0x07,
    AC_LOCK_Temperature_Mode = 0x08,
    AC_LOCK_Temperature_Speed = 0x09,
    AC_LOCK_Mode_Speed = 0x0A,
    AC_LOCK_Switch_Temperature_Mode = 0x0B,
    AC_LOCK_Switch_Temperature_Speed = 0x0C,
    AC_LOCK_Switch_Mode_Speed = 0x0D,
    AC_LOCK_Mode_Temperature_Speed = 0x0E,
    AC_LOCK_All = 0xFF,
}AC_LOCK_Typedef;

typedef enum {
    AC_REG_06_1000_Switch = 0x00,
    AC_REG_06_1001_Mode,
    AC_REG_06_1002_Speed,
    AC_REG_06_1003_Tmp,
    AC_REG_06_1004_Humidity,
    AC_REG_06_1004_Sleep,
    AC_REG_06_1004_Swing,
    AC_REG_06_1005_Lock,
}AC_REG_06_Typedef;

typedef enum {
    AC_DEVICE_MainDevice,
    AC_DEVICE_Diningroom,
    AC_DEVICE_Livingroom,
    AC_DEVICE_SouthBedroom,
    AC_DEVICE_MainBedroom,
    AC_DEVICE_NorthBedroom,
    AC_DEVICE_Num,
}AC_DEVICE_Typedef;


typedef struct mcquay_air_condition_device_info
{
    /* seted data */
    uint16_t Holding[11];

    /* read data */
    int16_t RoomTemperature;
    uint16_t CurrentMode;
    uint16_t CurrentSpeed;
    uint16_t CurrentSwitch;
    uint16_t SetTemperatureReadBack:9;
    uint16_t SetHumidityReadBack:7;
    uint16_t InternalDeviceFault;
    uint16_t MainDeviceDriver1Fault;
    uint16_t MainDeviceDriver2Fault;
    uint8_t VIPMode:1;
    uint8_t NetOnlineStatus:1;;
    uint8_t IsSupportDehumidificationReheating:1;
    uint8_t TemperatureControlMode:1; /* 0--RomeTemperature 1--BackWindTemperature */
    uint8_t SetSwitchReadBack:1;
    uint8_t SetSleepReadBack:1;
    uint8_t IsSwing:1;
    uint8_t HasFault:1;
    uint8_t TemperatureControlerSetSpeedReadBack;
    uint8_t SetSpeedReadBack;
    uint8_t SetModeReadBack;
    uint8_t SetLockReadBack;
    uint8_t SupportRefrigeration:1;
    uint8_t SupportHeating:1;
    uint8_t SupportAirsupply:1;
    uint8_t SupportAutomatic:1;
    uint8_t SupportFloorheating:1;
    uint8_t SupportDehumidificatio:1;
    uint8_t SupportDehumidification_Reheating:1;
    uint8_t reserved_1:1;
}AC_Mcquay_DeviceInfo_Typedef;

void mcquay_parse_sensor_status( uint16_t start_addr, uint8_t * data, uint8_t data_len );
uint8_t mcquay_tx_msg_package( AC_DEVICE_Typedef device, AC_REG_06_Typedef reg, uint16_t data, uint8_t * payload);
